function [ ylc ] = localmean(y,period)
%UNTITLED2 Summary of this function goes here
%   Detailed explanation goes here

y1 = y;
y2 = [y1(ceil(period/2)+1:end,:);nan(ceil(period/2),1) ];

laggedy = mlag2(y1,ceil(period/2));
leadedy = mlag2(y2,ceil(period/2));

matrix = [laggedy y1 leadedy];
ylc = nanmean(matrix,2);

end

